#ifndef ENEMY_H
#define ENEMY_H


#include "player.h"

class Enemy : public Actor {
    enum class State {
        NORMAL,
        HURT,
        DIE
    };

    State current_state_ = State::NORMAL;
    Player *target_ = nullptr; // 目标玩家
    SpriteAnim *anim_normal_ = nullptr;
    SpriteAnim *anim_hurt_ = nullptr;
    SpriteAnim *anim_die_ = nullptr;
    SpriteAnim *current_anim_ = nullptr;
    int score_ = 10;

public:
    static Enemy *addEnemyChild(Object *parent, glm::vec2 pos, Player *target);

    void init() override; // 初始化
    void update(float dt) override; // 更新
    void aim_target(Player *target); // 瞄准目标
    void setTarget(Player *target) { target_ = target; } // 设置目标
    Player *getTarget() const { return target_; } // 获取目标
    void checkState();

    void changeState(State new_state);

    void remove();

    void attack();
};
#endif // ENEMY_H
